@model ShippingSettingsModel

@{
    //page title
    ViewBag.Title = T("Admin.Configuration.Settings.Shipping").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Shipping settings");
}

<form asp-controller="Setting" asp-action="Shipping" method="post">
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @T("Admin.Configuration.Settings.Shipping")
        </h1>
        <div class="pull-right">
            <button type="submit" name="save" class="btn bg-blue">
                <i class="fa fa-floppy-o"></i>
                @T("Admin.Common.Save")
            </button>
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ShippingSettingsButtons })
        </div>
    </div>

    <div class="content">
        <div class="form-horizontal">
            @await Component.InvokeAsync("StoreScopeConfiguration")
            @await Component.InvokeAsync("SettingMode")
            <div asp-validation-summary="All"></div>

            <div class="panel-group">
                @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ShippingSettingsTop })
                <div class="panel panel-default">
                    <div class="panel-heading">
                        @T("Admin.Configuration.Settings.Shipping.BlockTitle.Common")
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="AllowPickUpInStore_OverrideForStore" asp-input="AllowPickUpInStore" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="AllowPickUpInStore" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="AllowPickUpInStore" />
                                <span asp-validation-for="AllowPickUpInStore"></span>
                            </div>
                        </div>
                        <nop-nested-setting asp-for="AllowPickUpInStore">
                            <div class="form-group advanced-setting" id="pnlDisplayPickupPointsOnMap">
                                <div class="col-md-3">
                                    <nop-override-store-checkbox asp-for="DisplayPickupPointsOnMap_OverrideForStore" asp-input="DisplayPickupPointsOnMap" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                    <nop-label asp-for="DisplayPickupPointsOnMap" />
                                </div>
                                <div class="col-md-9">
                                    <nop-editor asp-for="DisplayPickupPointsOnMap" />
                                    <span asp-validation-for="DisplayPickupPointsOnMap"></span>
                                </div>
                            </div>
                            <nop-nested-setting asp-for="DisplayPickupPointsOnMap">
                                <div class="form-group advanced-setting" id="pnlGoogleMapsApiKey">
                                    <div class="col-md-3">
                                        <nop-override-store-checkbox asp-for="GoogleMapsApiKey_OverrideForStore" asp-input="GoogleMapsApiKey" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                        <nop-label asp-for="GoogleMapsApiKey" />
                                    </div>
                                    <div class="col-md-9">
                                        <nop-editor asp-for="GoogleMapsApiKey" />
                                        <span asp-validation-for="GoogleMapsApiKey"></span>
                                    </div>
                                </div>
                            </nop-nested-setting>
                        </nop-nested-setting>
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="FreeShippingOverXEnabled_OverrideForStore" asp-input="FreeShippingOverXEnabled" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="FreeShippingOverXEnabled" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="FreeShippingOverXEnabled" />
                                <span asp-validation-for="FreeShippingOverXEnabled"></span>
                            </div>
                        </div>
                        <nop-nested-setting asp-for="FreeShippingOverXEnabled">
                            <div class="form-group" id="pnlValueOfX">
                                <div class="col-md-3">
                                    <nop-override-store-checkbox asp-for="FreeShippingOverXValue_OverrideForStore" asp-input="FreeShippingOverXValue" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                    <nop-label asp-for="FreeShippingOverXValue" />
                                </div>
                                <div class="col-md-9">
                                    <nop-editor asp-for="FreeShippingOverXValue" asp-postfix="@Model.PrimaryStoreCurrencyCode"/>
                                    <span asp-validation-for="FreeShippingOverXValue"></span>
                                </div>
                            </div>
                            <div class="form-group advanced-setting" id="pnlValueOfXincltax">
                                <div class="col-md-3">
                                    <nop-override-store-checkbox asp-for="FreeShippingOverXIncludingTax_OverrideForStore" asp-input="FreeShippingOverXIncludingTax" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                    <nop-label asp-for="FreeShippingOverXIncludingTax" />
                                </div>
                                <div class="col-md-9">
                                    <nop-editor asp-for="FreeShippingOverXIncludingTax" />
                                    <span asp-validation-for="FreeShippingOverXIncludingTax"></span>
                                </div>
                            </div>
                        </nop-nested-setting>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="UseWarehouseLocation_OverrideForStore" asp-input="UseWarehouseLocation" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="UseWarehouseLocation" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="UseWarehouseLocation" />
                                <span asp-validation-for="UseWarehouseLocation"></span>
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="ConsiderAssociatedProductsDimensions_OverrideForStore" asp-input="ConsiderAssociatedProductsDimensions" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="ConsiderAssociatedProductsDimensions" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="ConsiderAssociatedProductsDimensions" />
                                <span asp-validation-for="ConsiderAssociatedProductsDimensions"></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default advanced-setting">
                    <div class="panel-heading">
                        @T("Admin.Configuration.Settings.Shipping.BlockTitle.Notifications")
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="NotifyCustomerAboutShippingFromMultipleLocations_OverrideForStore" asp-input="NotifyCustomerAboutShippingFromMultipleLocations" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="NotifyCustomerAboutShippingFromMultipleLocations" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="NotifyCustomerAboutShippingFromMultipleLocations" />
                                <span asp-validation-for="NotifyCustomerAboutShippingFromMultipleLocations"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="DisplayShipmentEventsToCustomers_OverrideForStore" asp-input="DisplayShipmentEventsToCustomers" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="DisplayShipmentEventsToCustomers" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="DisplayShipmentEventsToCustomers" />
                                <span asp-validation-for="DisplayShipmentEventsToCustomers"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="DisplayShipmentEventsToStoreOwner_OverrideForStore" asp-input="DisplayShipmentEventsToStoreOwner" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="DisplayShipmentEventsToStoreOwner" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="DisplayShipmentEventsToStoreOwner" />
                                <span asp-validation-for="DisplayShipmentEventsToStoreOwner"></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        @T("Admin.Configuration.Settings.Shipping.BlockTitle.Checkout")
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="EstimateShippingEnabled_OverrideForStore" asp-input="EstimateShippingEnabled" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="EstimateShippingEnabled" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="EstimateShippingEnabled" />
                                <span asp-validation-for="EstimateShippingEnabled"></span>
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="HideShippingTotal_OverrideForStore" asp-input="HideShippingTotal" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="HideShippingTotal" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="HideShippingTotal" />
                                <span asp-validation-for="HideShippingTotal"></span>
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="ShipToSameAddress_OverrideForStore" asp-input="ShipToSameAddress" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="ShipToSameAddress" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="ShipToSameAddress" />
                                <span asp-validation-for="ShipToSameAddress"></span>
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                <nop-override-store-checkbox asp-for="BypassShippingMethodSelectionIfOnlyOne_OverrideForStore" asp-input="BypassShippingMethodSelectionIfOnlyOne" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                                <nop-label asp-for="BypassShippingMethodSelectionIfOnlyOne" />
                            </div>
                            <div class="col-md-9">
                                <nop-editor asp-for="BypassShippingMethodSelectionIfOnlyOne" />
                                <span asp-validation-for="BypassShippingMethodSelectionIfOnlyOne"></span>
                            </div>
                        </div>
                    </div>
                    <script>
                        $(document).ready(function () {
                            $("#@Html.IdFor(model => model.AllowPickUpInStore)").click(toggleAllowPickUpInStore);
                            $("#@Html.IdFor(model => model.DisplayPickupPointsOnMap)").click(toggleAllowPickUpInStore);
                            $("#@Html.IdFor(model => model.FreeShippingOverXEnabled)").click(toggleFreeShippingOverX);
                            toggleAllowPickUpInStore();
                            toggleFreeShippingOverX();
                        });

                        function toggleAllowPickUpInStore() {
                            if ($('#@Html.IdFor(model => model.AllowPickUpInStore)').is(':checked')) {
                                $('#pnlDisplayPickupPointsOnMap').show();
                                if ($('#@Html.IdFor(model => model.DisplayPickupPointsOnMap)').is(':checked')) {
                                    $('#pnlGoogleMapsApiKey').show();
                                } else {
                                    $('#pnlGoogleMapsApiKey').hide();
                                }
                            } else {
                                $('#pnlDisplayPickupPointsOnMap').hide();
                                $('#pnlGoogleMapsApiKey').hide();
                            }
                        }

                        function toggleFreeShippingOverX() {
                            if ($('#@Html.IdFor(model => model.FreeShippingOverXEnabled)').is(':checked')) {
                                $('#pnlValueOfX').show();
                                $('#pnlValueOfXincltax').show();
                            } else {
                                $('#pnlValueOfX').hide();
                                $('#pnlValueOfXincltax').hide();
                            }
                        }

                    </script>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <nop-override-store-checkbox asp-for="ShippingOriginAddress_OverrideForStore" asp-parent-container="pnlShippingOriginAddress" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        @T("Admin.Configuration.Settings.Shipping.ShippingOriginAddress")
                    </div>
                    <div class="panel-body">
                        <div id="pnlShippingOriginAddress">
                            <nop-editor asp-for="ShippingOriginAddress" asp-template="Address" />
                        </div>
                    </div>
                </div>
                @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ShippingSettingsBottom })
            </div>
        </div>
    </div>
</form>